const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
  mode: 'development',
  entry: './src/index.ts',
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist'),
    clean: true
  },
  devtool: 'inline-source-map',
  devServer: {
    port: 2335,
    contentBase: './dist',
  },
  resolve: {
      extensions: [".ts", ".tsx", ".js"]
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
     title: 'TSDemo',
     template: './public/index.html'
    }),
    new CopyWebpackPlugin({
      patterns: [{
        from: './public/favicon.ico',
        to:  './favicon.ico', 
        toType: 'file'
      }]
    })
  ]
};
